<?php
// +----------------------------------------------------------------------
// | @filename CreatePermissionRequest.php
// +----------------------------------------------------------------------
// | @author 落花轻舞问君愁 <mwcx1990@qq.com>
// +----------------------------------------------------------------------
// | @datetime 2021-10-29 18:31:04
// +----------------------------------------------------------------------
// | @Description
// +----------------------------------------------------------------------

namespace Addons\Backend\Http\Requests\Permission;


use Addons\Backend\Http\Requests\BaseRequest;

class CreatePermissionRequest extends BaseRequest
{
    public function rules(): array
    {
        return [
            'display_name' => ['bail', 'required', 'min:2', 'max:40'],
            'name' => ['bail', 'required', 'min:2', 'max:255', 'unique:permissions,name'],
        ];
    }

    public function messages(): array
    {
        return [
            'name.required' => '请输入权限规则',
            'name.unique' => '权限规则已存在',
            'name.min' => '权限规则不能少于2位',
            'name.max' => '权限规则不能大于255位',
            'display_name.required' => '请输入权限名称',
            'display_name.min' => '权限名称不能少于2位',
            'display_name.max' => '权限名称不能大于40位'
        ];
    }

    public function authorize(): bool
    {
        return true;
    }
}
